function init_image_modal(){
/* Declaring a UL with an ID of #meey_model_image_list */
    $('#meey_model_image_list li a').click(function(e) {
        e.preventDefault();
		activateCover();
		var id = $('#gallery');
		var galimg = $('#galimage');
	 	var img = new Image();
		img.onload = function(){
			buildFadeInModal(id, 
						$(window).height()/2-img.height/2, 
						$(window).width()/2-img.width/2, 
						img.width, 
						img.height, 
						1000);
			loadImagesIntoDiv(galimg, img.width, img.height, img.src);
		}
		img.src = $(this).attr('href');
    });
    
	function buildFadeInModal(modID, top, left, imgWidth, imgHeight, fadeMili){
	    $(modID).css('top', top);
        $(modID).css('left', left);
		$(modID).css('width', imgWidth);
        $(modID).css('height', imgHeight);
        $(modID).fadeIn(fadeMili);
	}
		
	function activateCover(){
	    var coverHeight = $(document).height();
        var coverWidth = $(window).width();
        $('#cover').css({'width':coverWidth,'height':coverHeight});  
        $('#cover').stop().fadeIn(1000);   
        $('#cover').stop().fadeTo('slow',0.8);
	}
	
	function loadImagesIntoDiv(divId, imgWidth, imgHeight, srcUrl){
		$(divId).css('background-image','url(' + srcUrl + ')' );
		$(divId).css('background-repeat','no-repeat');
		$(divId).css('width', imgWidth);
        $(divId).css('height', imgHeight);
	}
	
    /* Look for clicks that close the modal	*/
    $('.window .close').click(function(e){
        e.preventDefault();
        $('#cover, .window').hide();
    });    
     
    $('#cover').click(function(){
        $(this).hide();
        $('.window').hide();
    });
}

function init_rss(){
	$('#rss').rssfeed('http://feeds.bbci.co.uk/news/technology/rss.xml', {
		limit: 5
	});
}
			
$(document).ready(function() { 
	init_rss();	
	init_image_modal();

});



